package com.mt.api.modules.convert;

import com.google.common.collect.Lists;
import com.mt.api.modules.domain.InstoreDetail;
import com.mt.api.modules.domain.vo.AppInstoreVo;
import com.mt.api.util.ColorSizeSortUtil;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: plover
 * @Date: 2022/01/05 5:06 下午
 * @Description:
 */
public class AppInstoreConvert {

    public static List<AppInstoreVo.InstoreDetailVo> convertToDetailVoList(List<InstoreDetail> instoreDetailList) {
        if (CollectionUtils.isEmpty(instoreDetailList)) {
            return Lists.newArrayList();
        }
        List<AppInstoreVo.InstoreDetailVo> instoreDetailVoList = instoreDetailList.stream().map(instoreDetail -> {
            AppInstoreVo.InstoreDetailVo instoreDetailVo = new AppInstoreVo.InstoreDetailVo();
            instoreDetailVo.setCargoNo(instoreDetail.getCargoNo());
            instoreDetailVo.setColor(instoreDetail.getColor());
            instoreDetailVo.setSize(instoreDetail.getSize());
            instoreDetailVo.setQty(instoreDetail.getQty());
            return instoreDetailVo;
        }).collect(Collectors.toList());
        return ColorSizeSortUtil.instoreSort(instoreDetailVoList);
    }
}
